package com.babble.user.exception;

import lombok.extern.slf4j.Slf4j;
import org.springblade.common.exception.MsgException;
import org.springblade.core.tool.api.R;
import org.springframework.http.HttpStatus;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseStatus;
import org.springframework.web.bind.annotation.RestControllerAdvice;

@Slf4j
@RestControllerAdvice
public class GlobalExceptionHandler {

	@ExceptionHandler(value = MsgException.class)
	@ResponseStatus(HttpStatus.BAD_REQUEST)
	public R exceptionHandler(MsgException e) {
		return R.fail(e.getCode(), e.getMessage());
	}
}

